package main

import (
	"fmt"
)

func main() {
	createfile("/tmp/defer.txt")
	// defer会在writeFile执行后执行
	defer closeFile()
	writeFile()
}

func createfile(p string) {
	fmt.Println("creating")
}
func writeFile() {
	fmt.Println("writing")
}
func closeFile() {
	fmt.Println("closing")
}
